<template>
	<view class="page-index page-live p-l-30 p-r-30 p-b-10">
		<pageHeader title="发现好物"></pageHeader>
		
		<view class="df wrap margin-bottom-120">
			<goodItem v-for="item in list" :key="item.id" :good="item" ></goodItem>
		</view>
		<pageFooter ref="footer"></pageFooter>
	</view>
</template>

<script>
	import searchHeader from '../../components/searchHeader.vue'
	import zhenxianItem from '../../components/zhenxianItem.vue'
	import flashSaleCard from '../../components/flashSaleCard.vue'
	import goodItem from '../../components/goodItem.vue'
	export default {
		components: {
			searchHeader,
			zhenxianItem,
			flashSaleCard,
			goodItem
		},
		data() {
			return {
				nav:[
					{id:1,name:'热销',icon:require('../../static/imgs/i1.png')},
					{id:2,name:'推荐',icon:require('../../static/imgs/i2.png')},
					{id:3,name:'精选',icon:require('../../static/imgs/i3.png')},
					{id:4,name:'新品',icon:require('../../static/imgs/i4.png')},
					{id:5,name:'连衣裙',icon:require('../../static/imgs/i5.png')},
					{id:6,name:'T恤',icon:require('../../static/imgs/i6.png')},
					// {id:7,name:'热销',icon:require('../../static/imgs/i7.png')},
					{id:8,name:'运动裤',icon:require('../../static/imgs/i8.png')},
					{id:9,name:'卫衣',icon:require('../../static/imgs/i9.png')},
				],
				list:[
					// {id:1,title:'炸街保障，新品预览',name:'Mona',position:'杭州市',avatar:require('../../static/imgs/user.jpg'),img:'https://z3.ax1x.com/2021/08/08/f1ZNHH.jpg'},
					// {id:2,title:'炸街保障，新品预览',name:'Mona',position:'杭州市',avatar:require('../../static/imgs/user.jpg'),img:'https://z3.ax1x.com/2021/08/08/flFJfO.jpg'},
					// {id:3,title:'炸街保障，新品预览',name:'Mona',position:'杭州市',avatar:require('../../static/imgs/user.jpg'),img:'https://z3.ax1x.com/2021/08/08/flF8k6.jpg'},
					// {id:4,title:'炸街保障，新品预览',name:'Mona',position:'杭州市',avatar:require('../../static/imgs/user.jpg'),img:'https://z3.ax1x.com/2021/08/08/flFGtK.jpg'},
				],
				page:1,
				flag:"hao",
				keyword:"",
				query: {
					"type": 'goods_list', // 商品类型
					"page": 0, // 第几页
					"size": 100, // 每页返回个数
					"order_by": "id|desc",// 排序字段
					//"is_rec":1
				},
			}
		},
		onShow() {
			if(this.$refs.footer) {
				this.$refs.footer.cur =1
			}
		},
		created() {
		},
		onLoad(options) {
			if(options.flag){
				this.flag = options.flag
			}
			if(options.keyword){
				this.keyword = options.keyword
			}
			
			this.init()
		},
		onReachBottom() {
			console.log('bottom')
		},
		methods: {
			async init() {
				var query = this.query;
				query.flag = this.flag;
				query.sgoods = this.keyword;
				 let res = await this.$api.goodsData(query).then(res=> {
					 console.log("商品列表")
						console.log(res)
						if(res.code == 0){
							this.list = res.list;
							console.log(this.list);
						}
						this.loadShow = false;
				 }).catch(err=> { console.log(err) }
				 );
			},
			
		}
	}
</script>

<style lang="scss">

	.page-header{
		padding-top: 50rpx !important;
		padding-bottom: 50rpx !important;
	}
	.page-index {
		.swiper {
			height: 690rpx;
			
			.swiper-item {
				height: 690rpx;
				border-radius: 30rpx;
				overflow: hidden;
				image {
					width: 100%;
					height: 690rpx;
				}
			}
		}
		.nav {
			.nav-item {
				text-align: center;
				font-size: 22rpx;
				flex: 0 0 25%;
				margin-bottom: 30rpx;
				image {
					width: 76rpx;
					height: 76rpx;
				}
			}
		}
		.block-title {
			color: #282A32;
			margin-bottom: 40rpx;
			.tag {
				width: 80rpx;
				height: 40rpx;
				line-height: 40rpx;
				border-radius: 20rpx;
				background-color: #8663E8;
				color: #fff;
				font-size: 26rpx;
				text-align: center;
				margin-left: 15rpx;
			}
			.more {
				padding-right: 30rpx;
				position: relative;
				&::after {
					content: '';
					position: absolute;
					right: 0;
					top: 50%;
					transform: translateY(-50%);
					width: 0;
					height: 0;
					border-left: 14rpx solid #282A32;
					border-top: 10rpx solid transparent;
					border-bottom: 10rpx solid transparent;
				}
			}
		}
		.live-container {
			overflow-y: scroll;
			padding-bottom: 60rpx;
		}
	}
</style>
